<template>
	<view>
		<image class="bgImage" src="/static/image/guide/homeBg.png" mode="widthFix"></image>
		<view class="navBox">
			<image class="backBtn" @click="goBack" src="http://cdn.yic3.cn/lawyer/mp-xhs/mine/backIcon.png"
				mode="widthFix"></image>
			<p>{{dataObj.name}}分类</p>
		</view>
		<view class="" style="width: 100%;height: 188rpx;"></view>
		<scroll-view @scrolltolower="list2Lower" class="contractList" :scroll-y="true" v-if="contractList.length">
			<view class="listItem" v-for="(item,index) in contractList"
				@click="goItemDetail('/packageA/pages/lawsuitWrite/lawsuitWrite',{item:JSON.stringify(item),module:dataObj.id})"
				:key="index">
				<view class="itemTop">
					<p>{{item.name}}</p>
					<p>
						<image src="http://cdn.yic3.cn/lawyer/mp-xhs/contract/icon1.png" mode=""></image>
						<text>{{item.viewNum}}</text>
					</p>
				</view>
				<p class="itemText">{{item.describe}}</p>
			</view>
			<view class="noMore" v-if="loadingOver">
				没有更多数据
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				contractList: [],
				dataObj: {},
				page: 1,
				loading: false,
				loadingOver: false
			};
		},
		onLoad(e) {
			this.dataObj = e
			console.log(e)
			this.getContract()
		},
		methods: {
			getContract() {
				this.loading = true
				uni.showLoading()
				uni.$api.getContractType({
					page: this.page,
					size: 10,
					typeId: this.dataObj.id
				}).then(res => {
					this.loading = false
					uni.hideLoading()
					if (res.data.code == 0) {
						if (res.data.data.items.length < 10) this.loadingOver = true
						this.contractList = [...this.contractList, ...res.data.data.items]
					}
				})
			},
			list2Lower() {
				if (this.loadingOver || this.loading) return
				this.page++
				this.getContract()
			}
		},
	}
</script>

<style lang="scss">
	@import 'writeClassification.scss'
</style>